// Printer.cpp: implementation of the CPrinter class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "8085.h"
#include "Printer.h"
#include "MyException.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPrinter::CPrinter()
{

}

CPrinter::~CPrinter()
{

}

// write the string "str" to LPT1
void CPrinter::Write(char *str)
{
    FILE *fp;
    char *tempName;
    static char err[1024];

    tempName = tmpnam("t876");
    if(!(fp=fopen(tempName,"wt")))
    {
        sprintf(err,"Cannot open temporary file<%s> used for printing",tempName);
        throw CMyException(severe,temporary_file_open,err);
    }
    fprintf(fp,"%s",str);
    fclose(fp);
    char szCommand[1024];
    sprintf(szCommand,"%s /c copy %s LPT1",getenv("COMSPEC"),tempName);
    system(szCommand);
}
            

